﻿
@{
    ViewBag.Title = "租赁展示";
}
<div style="top: 0;bottom: 0;width: 100%;position: absolute;">
    <div class="layui-show" style="width: 100% !important;height: 100% !important;">
        <iframe id='childFrame' style="width:100%;height:100%;" frameborder="0" src="@ViewBag.Url3D"></iframe>
    </div>
</div>
<script>
    layui.use(['jquery'], function () {
        var $ = layui.jquery;
        //updateData();
        function updateData() {
            $.ajax({
                url: 'ShowRent_Ajax',
                type: 'post',
                success: function (res) {
                    console.log(res);
                    callChildFunc("showRent", res.data);
                    // 每隔10s 请求一次数据
                    setTimeout(function () {
                        updateData();
                    }, 10000);
                }
            });
        }
        //setTimeout(function () {
        //    callChildFunc("setUser", "gaoqihang");
        //}, 10000);
    });

    function GetCurrentUserId() {
        callChildFunc("setUser", "gaoqihang");
    }

    //调用子页面函数
    function callChildFunc(funcName, data) {
        var iframe = window.frames['childFrame'];
        var message = {
            'funcName': funcName,
            'param': data
        }
        iframe.contentWindow.postMessage(message, '*');
    }
    //监听子页面调用本页面函数
    window.addEventListener('message', function (e) {
        var data = e.data;
        if (data.hasOwnProperty("funcName")) {
            var funcName = data.funcName;
            var param = data.param;
            window[funcName](param);
        }
    });
</script>